home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * XmlHttp.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
- if (!IS.isModuleInitialized("IS.NOF.XML.XmlHttp"))
- {
-
- /****h* NOF_JavaScript_Library/NOF.XML.XmlHttp
- *
- * NAME
- * NOF.XML.XmlHttp
- *
- * DESCRIPTION
- *
- *
- ****/
-
- /**
- * Constructor
- */
- function XML_XmlHttp( ) {
- this.__proto__ = XML_XmlHttp.prototype;
- }
- {
- var member = XML_XmlHttp.prototype;
-
- member.prefix = null;
- member.prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
-
- var method = XML_XmlHttp.prototype;
-
- /**
- * Private method. Used to find the Automation server name
- * Only for Microsoft's ActiveX.
- *
- * @return
- **/
- method.getXmlHttpPrefix = function () {
- if (this.prefix != null) {
- return ("" + this.prefix);
- }
-
- var o;
- for (var i = 0; i < this.prefixes.length; i++) {
- try {
- // try to create the objects
- o = new ActiveXObject(this.prefixes[i] + ".XmlHttp");
- this.prefix = this.prefixes[i];
- return ("" + this.prefix); //return this.getXmlHttpPrefix();
- } catch (ex) {
- }
- }
- //alert("Could not find an installed XML parser");
- throw new Error("Could not find an installed XML parser");
- //throw new NOF.UTIL.Exception();
- }
-
- /**
- * Creates an instance of the XmlHttp (XMLHttpRequest).
- *
- * @return
- **/
- method.create = function () { // document as param?
- try {
- if (window.ActiveXObject) {
- return new ActiveXObject(this.getXmlHttpPrefix() + ".XmlHttp");
- }
-
- if (window.XMLHttpRequest) {
- var req = new XMLHttpRequest();
-
- // some versions of Moz do not support the readyState property
- // and the onreadystate event so we patch it!
- if (req.readyState == null) {
- req.readyState = 1;
- req.addEventListener("load", function () {
- req.readyState = 4;
- if (typeof(req.onreadystatechange) == "function") {
- req.onreadystatechange();
- }
- }, false);
- }
-
- return req;
- }
- } catch (ex) {}
- // fell through
- //alert("Your browser does not support XmlHttp objects");
- throw new Error("Your browser does not support XmlHttp objects");
- //throw new NOF.UTIL.Exception();
- }
-
- }
-
- //XML.__proto__.XmlHttp = new XML_XmlHttp();
- NOF.XML.__proto__.XmlHttp = new XML_XmlHttp();
-
- }